#!/user/bin/env node

const log = console.log,
      http = require('http'),
      url = require('url');

const addr = 'http://localhost:3000';
const opt = url.parse(addr),
      msg = process.argv[2] || 'hello,i am liu';
opt.method = 'POST';  
//opt.headers = {};   //请求头
//opt中既有方法，又有地址
let req = http.request(opt,(res)=>{
  log(res.headers);
  log(`HTTP/${res.httpVersion} ${res.statusMessage}`);
  res.pipe(process.stdout);
});
req.end(msg);
